home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / BlueBox Spy / Blue Box Daemon / source / CSimpleTCPServer.h < prev    next >
Encoding:
Text File  |  1998-08-06  |  2.4 KB  |  85 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CSimpleTCPServer.h            ©1995-1998 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4.  
  5. #pragma once
  6.  
  7. #include <LSingleDoc.h>
  8. #include <LListener.h>
  9.  
  10. #include <LTCPEndpoint.h>
  11.  
  12. #include <LCaption.h>
  13.  
  14. #include "CTCPServerThread.h"
  15.  
  16. #define kMaxOutstanding 256        //Arbitrarily large number for the qlen param to bind command...
  17.                                 // I don't think that OT/TCP really cares what this value is
  18.                                 // as long as it's > 0.
  19. class CTCPServerThread;
  20.  
  21. // ===========================================================================
  22. //        • CSimpleTCPServer
  23. // ===========================================================================
  24.  
  25. class CSimpleTCPServer :    public PP_PowerPlant::LSingleDoc,
  26.                             public PP_PowerPlant::LListener  {
  27.  
  28. public:
  29.  
  30.                             CSimpleTCPServer(
  31.                                 LCommander* inSuper);
  32.             
  33.     void                    ListenToMessage(
  34.                                 PP_PowerPlant::MessageT        inMessage,
  35.                                 void *            ioParam);
  36.  
  37.     virtual PP_PowerPlant::LTCPEndpoint*    GetEndPoint() const;
  38.  
  39.     virtual void            WaitForConnections(
  40.                                 UInt32        inListenQueueSize,
  41.                                 UInt32        inPort);
  42.     
  43.     virtual void            CreateServerWindow(
  44.                                 UInt32        inListenQueueSize,
  45.                                 UInt32        inPort);
  46.     
  47.     virtual void            AddToConnectionCount(short theCount);
  48.     
  49.     virtual void            IncRejectionCount();
  50.  
  51.     virtual void            BindCompleted();
  52.     virtual void            BindFailed();
  53.     
  54.     virtual Boolean            IsIdle();
  55.     
  56.     virtual void            ServerThreadDied();
  57.     
  58.     virtual void            Disconnect();
  59.  
  60.     virtual Boolean            AllowSubRemoval(
  61.                                 LCommander *inSub);
  62.                                 
  63.     virtual Boolean            AttemptQuitSelf(
  64.                                 SInt32    inSaveOption);
  65.                                 
  66. protected:
  67.  
  68.         // this object MUST be created on the heap (we can't do a
  69.         // "delete this" very well with a stack-based object).
  70.     virtual                    ~CSimpleTCPServer();
  71.  
  72.     PP_PowerPlant::LTCPEndpoint*    mEndpoint;                // our network endpoint object
  73.     PP_PowerPlant::LCaption*         mConnectionCountField;    // field used to display current # of connections
  74.     PP_PowerPlant::LCaption*         mRejectionCountField;    // field used to display current # of rejected connections
  75.     UInt16                            mConnectionCount;
  76.     SInt32                            mRejectionCount;
  77.  
  78.     CTCPServerThread*                mServerThread;            // the thread that actually handles the connection
  79.     
  80.     bool                            mQuitWhenDone;            // re-issue quit request when disconnect complete
  81.     SInt32                            mSaveOption;
  82.  
  83.     friend class CTCPServerThread;
  84. };
  85.